package com.atguigu.facade;

/**
 * @program: design-patterns
 * @author: yangshen
 * @description: 外观类(影院外观)
 * @create: 2022-02-22 11:10
 **/
public class HomeTheaterFacade {
    /**
     * 定义各个子系统对象,子系统1-6
     */
    private DvdPlayer dvdPlayer;
    private Popcorn popcorn;
    private Projector projector;
    private Screen screen;
    private Stereo stereo;
    private TheaterLight theaterLight;

    /**
     * 将全参构造方法 改为 无参构造方法
     */
    public HomeTheaterFacade() {
        this.dvdPlayer = DvdPlayer.getInstance();
        this.popcorn = Popcorn.getInstance();
        this.projector = Projector.getInstance();
        this.screen = Screen.getInstance();
        this.stereo = Stereo.getInstance();
        this.theaterLight = TheaterLight.getInstance();
    }

    /**
     * 操作分为4步(1.准备；2.打开；3.暂停；4.结束)
     */
    public void ready(){
        //爆米花
        popcorn.on();
        popcorn.pop();
        //屏幕
        screen.down();
        //投影仪
        projector.on();
        //立体声
        stereo.on();
        //dvd
        dvdPlayer.on();
        //灯光
        theaterLight.dim();
    }

    public void play(){
        dvdPlayer.play();
    }

    public void pause(){
        dvdPlayer.pause();
    }

    public void end(){
        //爆米花
        popcorn.off();
        //屏幕
        screen.up();
        //投影仪
        projector.off();
        //立体声
        stereo.off();
        //dvd
        dvdPlayer.off();
        //灯光
        theaterLight.bright();
    }
}
